﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Practices.Composite.Presentation.Commands;

namespace Core.Infrastructure.CommandExtensions
{
    public class ControlLoadedCommandBehavior : CommandBehaviorBase<Control>
    {
        public ControlLoadedCommandBehavior(Control targetObject) : base(targetObject)
        {
            targetObject.Loaded += new RoutedEventHandler(TargetObjectLoaded);
        }

        void TargetObjectLoaded(object sender, RoutedEventArgs e)
        {
            base.CommandParameter = sender;
            base.ExecuteCommand();
        }
    }
}
